from time import sleep
import uiautomation
import pyautogui
class tuikuanchuli():
        his = uiautomation.WindowControl(searchDepth=1, Name='科玛奇医院信息管理系统')  # 锁定窗口
        his.SetFocus()

        chaxun = his.ButtonControl(AutomationId='btnQuery', ClassName='Button',Name='查询')#查询按钮
        tuikuan = his.ButtonControl(AutomationId='btnTuiKuan', ClassName='Button', Name='退款')#退款按钮
        bufentuifeifuxuankuang = his.CheckBoxControl(ClassName='CheckBox', Name='部分退费')#部分退款复选框
        xingmingshurukuang = his.EditControl(AutomationId='tbXingming', ClassName='TextBox')#姓名输入框


        shujuwangge1 = his.DataGridControl(AutomationId='dgShouFeiList', ClassName='DataGrid')#收费记录数据网格
        shoufeijilushuju1 = shujuwangge1.DataItemControl(ClassName='DataGridRow', Name='Ksy.ChssClient.Access.Model.MZ_SFJLLIST',foundIndex=1)
        shoufeijilushuju2 = shujuwangge1.DataItemControl(ClassName='DataGridRow', Name='Ksy.ChssClient.Access.Model.MZ_SFJLLIST',foundIndex=2)
        shoufeijilushuju3 = shujuwangge1.DataItemControl(ClassName='DataGridRow', Name='Ksy.ChssClient.Access.Model.MZ_SFJLLIST',foundIndex=3)
        shoufeijilushuju4 = shujuwangge1.DataItemControl(ClassName='DataGridRow', Name='Ksy.ChssClient.Access.Model.MZ_SFJLLIST',foundIndex=4)
        shoufeijilushuju5 = shujuwangge1.DataItemControl(ClassName='DataGridRow', Name='Ksy.ChssClient.Access.Model.MZ_SFJLLIST',foundIndex=5)


        shujuiwangge2 = his.DataGridControl(AutomationId='dgChuFangList', ClassName='DataGrid')#退款处方数据网格
        quanxuanbiaotou = shujuiwangge2.HeaderControl(AutomationId='PART_ColumnHeadersPresenter', ClassName='DataGridColumnHeadersPresenter').HeaderItemControl(ClassName='DataGridColumnHeader')
        tuikuanchufangshuju1 = shujuiwangge2.GroupControl(ClassName='GroupItem', foundIndex=1).DataItemControl(ClassName='DataGridRow', Name='Yuanbo.ChssClient.OutFeeManager.ViewModel.SQ_SF2VM',foundIndex=1).CustomControl(ClassName='DataGridCell', Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.SQ_SF2VM，列显示索引: 0')
        tuikuanchufangshuju2 = shujuiwangge2.GroupControl(ClassName='GroupItem', foundIndex=2).DataItemControl(ClassName='DataGridRow', Name='Yuanbo.ChssClient.OutFeeManager.ViewModel.SQ_SF2VM',foundIndex=1).CustomControl(ClassName='DataGridCell', Name='项: Yuanbo.ChssClient.OutFeeManager.ViewModel.SQ_SF2VM，列显示索引: 0')

        tishiqueding = his.ButtonControl(AutomationId='OkBtn', ClassName='Button',Name='确定')
        tishiquxiao = his.ButtonControl(AutomationId='CancelBtn', ClassName='Button', Name='取消')

        tuifeixiangqingqueding = his.WindowControl(ClassName='Window',Name='退费详情').CustomControl(ClassName='PartRefundDetailView').ButtonControl(ClassName='Button',Name='确定')
        #点击查询按钮
        def click_cx_btn(self):
                self.chaxun.Click()
        #点击退款按钮
        def click_tk_btn(self):
                self.tuikuan.Click()
        #点击部分退款复选框
        def click_bft_btn(self):
                self.bufentuifeifuxuankuang.Click()
        #输入姓名
        def input_name(self,name):
                self.xingmingshurukuang.Click()
                pyautogui.hotkey('ctrl', 'a')
                pyautogui.hotkey('back')
                self.xingmingshurukuang.SendKeys(name)
        #点击收费数据1
        def click_sfsj1(self):
                self.shoufeijilushuju1.Click()

        #点击收费数据2
        def click_sfsj2(self):
                self.shoufeijilushuju2.Click()

        #点击收费数据3
        def click_sfsj3(self):
                self.shoufeijilushuju3.Click()

        #点击收费数据4
        def click_sfsj4(self):
                self.shoufeijilushuju4.Click()

        #点击收费数据5
        def click_sfsj5(self):
                self.shoufeijilushuju5.Click()

        #点击全选标头
        def click_qxbt(self):
                self.quanxuanbiaotou.Click()

        #点击处方1数据标头
        def click_sj1bt(self):
                self.tuikuanchufangshuju1.Click()

        # 点击处方2数据标头
        def click_sj2bt(self):
                self.tuikuanchufangshuju2.Click()

        #点击提示确定按钮
        def click_tsqd_btn(self):
                self.tishiqueding.Click()
        #点击提示取消按钮
        def click_tsqx_btn(self):
                self.tishiquxiao.Click()

        #点击退费详情确定按钮
        def click_tfxqqd_btn(self):
                self.tuifeixiangqingqueding.Click()